/*
    Linear Programming Library
    
    Created by Team Paragon (Shena Hoffmann, Arthur Powalka, Nasir Kenarangui)
    CSCE 689
    
    Exceptions.cpp
    Implements the Exception classes used for checking user input.
*/

#include "Exceptions.h"

// --------- Generic LinProg Exception Class ---------

const char* LinProgException::what() const throw()
{
    return "LinProg Exception";
}

// --------- InvalidInequalityException class ---------
// Indicates that the inequality operators are not of the expected form

const char* InvalidInequalityException::what() const throw()
{
    return "Inequality operators are invalid. Should only be \"<=\", \">=\", or \"=\".";
}

// --------- InvalidCoeffsException class ---------
// Indicates that the coefficients of either the objective function, constraint function, or constrained variables are not the same size

InvalidCoeffsException::InvalidCoeffsException(string problemVar)
{
    problem = problemVar;
}

const char* InvalidCoeffsException::what() const throw()
{
    if (problem == "objective")
        return "Invalid number of coefficients. Objective function should have the same number of coefficients as each of the constraint functions.";
    else if (problem == "vars")
        return "Invalid number of coefficients. The number of constrained variables should equal the number of coefficients in the objective function and each of the constraint functions.";
    else if (problem == "constraints")
        return "Invalid number of coefficients. Each constraint equation should have the same number of coefficients.";
}

// --------- InvalidConstraintsException class ---------
// Indicates that the number of constraints equations does not match the number of right-hand side equation values or the number of inequality operators

InvalidConstraintsException::InvalidConstraintsException(string problemVar)
{
    problem = problemVar;
}

const char* InvalidConstraintsException::what() const throw()
{
    if (problem == "signs")
        return "Invalid constraint equations. The number of constraint equations should be equal to the number of inequality signs.";
    else if (problem == "vals")
        return "Invalid constraint equations. The number of constraint equations should be equal to the number of inequality values.";
}